const { cloud } = getApp();
Page({
  data: {
    imageList: [
      {
        "author": "祖海",
        "name": "好运来",
        "id": 1,
        "type": "bgMusic",
        "url": "https://gshow.ewszjk.m.jaeapp.com/Public/music/good_luck.mp3"
      },
      {
        "author": "香香",
        "name": "恭喜恭喜",
        "id": 2,
        "type": "bgMusic",
        "url": "https://gshow.ewszjk.m.jaeapp.com/Public/music/congratulate.mp3"
      },
      {
        "author": "汤灿",
        "name": "开门红",
        "id": 3,
        "type": "bgMusic",
        "url": " https://gshow.ewszjk.m.jaeapp.com/Public/music/good_start.mp3"
      },
      {
        "author": "宋祖英",
        "name": "好日子",
        "id": 4,
        "type": "bgMusic",
        "url": " https://gshow.ewszjk.m.jaeapp.com/Public/music/good_day.mp3"
      },
      {
        "author": "刘德华",
        "name": "恭喜发财",
        "id": 5,
        "type": "bgMusic",
        "url": "https://gshow.ewszjk.m.jaeapp.com/Public/music/fortune.mp3"
      },
      {
        "author": "",
        "name": "斗牛士之歌",
        "id": 6,
        "type": "bgMusic",
        "url": " https://gshow.ewszjk.m.jaeapp.com/Public/music/toreador.mp3"
      },
      {
        "author": "",
        "name": "",
        "id": 7,
        "type": "boxImage",
        "url": "https://img.alicdn.com/imgextra/i4/376771766/O1CN01lkS8Dk1Ous2NVcPMP_!!376771766.png "
      },
      {
        "author": "",
        "name": "",
        "id": 8,
        "type": "boxImage",
        "url": "https://img.alicdn.com/imgextra/i2/376771766/O1CN01LxTaBI1Ous2M34pFn_!!376771766.png "
      },
      {
        "author": "",
        "name": "",
        "id": 9,
        "type": "boxImage",
        "url": "https://img.alicdn.com/imgextra/i1/376771766/O1CN01rEzScH1Ous2Pozp5b_!!376771766.png "
      },
      {
        "author": "",
        "name": "",
        "id": 10,
        "type": "boxImage",
        "url": "https://img.alicdn.com/imgextra/i3/376771766/O1CN01zDuqbk1Ous2Q119lO_!!376771766.png "
      },
      {
        "author": "",
        "name": "",
        "id": 11,
        "type": "boxImage",
        "url": "https://img.alicdn.com/imgextra/i1/376771766/O1CN01gAkmmH1Ous2OLpVS9_!!376771766.png "
      },
      {
        "author": "",
        "name": "",
        "id": 12,
        "type": "boxImage",
        "url": "https://img.alicdn.com/imgextra/i4/376771766/O1CN01ImvbLp1Ous2G47RwL_!!376771766.png "
      },
      {
        "author": "",
        "name": "",
        "id": 13,
        "type": "boxImage",
        "url": "https://img.alicdn.com/imgextra/i4/376771766/O1CN01CrcExq1Ous2LgKrgP_!!376771766.png "
      },
      {
        "author": "",
        "name": "",
        "id": 14,
        "type": "boxImage",
        "url": "https://img.alicdn.com/imgextra/i4/376771766/O1CN01rjxnP31Ous2No67ps_!!376771766.png "
      },
      {
        "author": "",
        "name": "",
        "id": 15,
        "type": "boxImage",
        "url": "https://img.alicdn.com/imgextra/i3/376771766/O1CN01KsNOOL1Ous2G45ZXK_!!376771766.png "
      },
      {
        "author": "",
        "name": "",
        "id": 16,
        "type": "boxImage",
        "url": "https://img.alicdn.com/imgextra/i3/376771766/O1CN01W6x6kf1Ous2Ny66ff_!!376771766.png "
      },
      {
        "author": "",
        "name": "",
        "id": 17,
        "type": "boxImage",
        "url": "https://img.alicdn.com/imgextra/i1/376771766/O1CN01STs5li1Ous2QoTiom_!!376771766.png "
      },
      {
        "author": "",
        "name": "",
        "id": 18,
        "type": "boxImage",
        "url": "https://img.alicdn.com/imgextra/i3/376771766/O1CN0149oPTh1Ous2S0Zjar_!!376771766.png "
      },
      {
        "author": "",
        "name": "",
        "id": 19,
        "type": "boxImage",
        "url": "https://img.alicdn.com/imgextra/i1/376771766/O1CN01XvWxgD1Ous2No3RY9_!!376771766.png"
      },
      {
        "author": "",
        "name": "",
        "id": 20,
        "type": "boxImage",
        "url": "https://img.alicdn.com/imgextra/i4/376771766/O1CN01XNnste1Ous2G47eOL_!!376771766.png "
      },
      {
        "author": "",
        "name": "",
        "id": 21,
        "type": "topImage",
        "url": "https://img.alicdn.com/imgextra/i1/376771766/O1CN01ZJFwoQ1Ous2SQamAS_!!376771766.png"
      },
      {
        "author": "",
        "name": "",
        "id": 22,
        "type": "topImage",
        "url": "https://img.alicdn.com/imgextra/i3/376771766/O1CN01h4w6V51Ous2OIkEbi_!!376771766.jpg"
      },
      {
        "author": "",
        "name": "",
        "id": 23,
        "type": "topImage",
        "url": "https://img.alicdn.com/imgextra/i3/376771766/O1CN01bn9TXH1Ous2SQZVCO_!!376771766.jpg "
      },
      {
        "author": "",
        "name": "",
        "id": 24,
        "type": "topImage",
        "url": "https://img.alicdn.com/imgextra/i1/376771766/O1CN01iYtnDH1Ous2NVaBvn_!!376771766.jpg"
      },
      {
        "author": "",
        "name": "",
        "id": 25,
        "type": "topImage",
        "url": "https://img.alicdn.com/imgextra/i1/376771766/O1CN01HSlfyr1Ous2PCbR76_!!376771766.jpg "
      },
      {
        "author": "",
        "name": "",
        "id": 26,
        "type": "topImage",
        "url": "https://img.alicdn.com/imgextra/i1/376771766/O1CN01LH7Wf81Ous2Ny41cm_!!376771766.jpg "
      },
      {
        "author": "",
        "name": "",
        "id": 27,
        "type": "topImage",
        "url": "https://img.alicdn.com/imgextra/i1/376771766/O1CN01Fm1XpH1Ous2QoRAjU_!!376771766.jpg "
      },
      {
        "author": "",
        "name": "",
        "id": 28,
        "type": "topImage",
        "url": "https://img.alicdn.com/imgextra/i2/376771766/O1CN01YggkSn1Ous2KjacYR_!!376771766.jpg"
      },
      {
        "author": "",
        "name": "",
        "id": 29,
        "type": "topImage",
        "url": "https://img.alicdn.com/imgextra/i2/376771766/O1CN01BehX9m1Ous2RMFeIu_!!376771766.jpg "
      },
      {
        "author": "",
        "name": "",
        "id": 30,
        "type": "topImage",
        "url": "https://img.alicdn.com/imgextra/i2/376771766/O1CN01wtqOJg1Ous2PCbdci_!!376771766.jpg "
      },
      {
        "author": "",
        "name": "",
        "id": 31,
        "type": "topImage",
        "url": "https://img.alicdn.com/imgextra/i4/376771766/O1CN01pEXD4X1Ous2Q10YAP_!!376771766.jpg "
      },
      {
        "author": "",
        "name": "",
        "id": 32,
        "type": "topImage",
        "url": "https://img.alicdn.com/imgextra/i1/376771766/O1CN01s8lGAW1Ous2NVbw6c_!!376771766.jpg "
      },
      {
        "author": "",
        "name": "",
        "id": 33,
        "type": "topImage",
        "url": "https://img.alicdn.com/imgextra/i1/376771766/O1CN018iOU401Ous2Ny5V72_!!376771766.jpg "
      },
      {
        "author": "",
        "name": "",
        "id": 34,
        "type": "topImage",
        "url": "https://img.alicdn.com/imgextra/i1/376771766/O1CN01tBSKh21Ous2Pox0Ly_!!376771766.jpg "
      },
      {
        "author": "",
        "name": "",
        "id": 35,
        "type": "topImage",
        "url": "https://img.alicdn.com/imgextra/i2/376771766/O1CN01EN2jCE1Ous2G44hJC_!!376771766.jpg "
      },
      {
        "author": "",
        "name": "",
        "id": 36,
        "type": "topImage",
        "url": "https://img.alicdn.com/imgextra/i1/376771766/O1CN01IblxtA1Ous2No0l1l_!!376771766.jpg "
      },
      {
        "author": "",
        "name": "",
        "id": 37,
        "type": "topImage",
        "url": "https://img.alicdn.com/imgextra/i4/376771766/O1CN01wux8L41Ous2M33ods_!!376771766.jpg "
      },
      {
        "author": "",
        "name": "",
        "id": 38,
        "type": "topImage",
        "url": "https://img.alicdn.com/imgextra/i3/376771766/O1CN010eHQoX1Ous2Ny3xPH_!!376771766.jpg "
      },
      {
        "author": "",
        "name": "",
        "id": 39,
        "type": "topImage",
        "url": "https://img.alicdn.com/imgextra/i1/376771766/O1CN01GSegp11Ous2PowjeD_!!376771766.jpg "
      },
      {
        "author": "",
        "name": "",
        "id": 40,
        "type": "topImage",
        "url": "https://img.alicdn.com/imgextra/i1/376771766/O1CN01RrfoXS1Ous2Kjakm9_!!376771766.jpg "
      },
      {
        "author": "",
        "name": "",
        "id": 41,
        "type": "topImage",
        "url": "https://img.alicdn.com/imgextra/i3/376771766/O1CN01TibvLn1Ous2LgIiPG_!!376771766.jpg "
      },
      {
        "author": "",
        "name": "",
        "id": 42,
        "type": "topImage",
        "url": "https://img.alicdn.com/imgextra/i1/376771766/O1CN01hNKFDd1Ous2NVYz5T_!!376771766.jpg "
      },
      {
        "author": "",
        "name": "",
        "id": 43,
        "type": "topImage",
        "url": "https://img.alicdn.com/imgextra/i1/376771766/O1CN01wIPhUy1Ous2NVXuYk_!!376771766.jpg "
      },
      {
        "author": "",
        "name": "",
        "id": 44,
        "type": "topImage",
        "url": "https://img.alicdn.com/imgextra/i4/376771766/O1CN01MLqjS81Ous2S0VVXF_!!376771766.jpg "
      },
      {
        "author": "",
        "name": "",
        "id": 45,
        "type": "topImage",
        "url": "https://img.alicdn.com/imgextra/i1/376771766/O1CN01DQ16Ze1Ous2M31GhS_!!376771766.jpg "
      },
      {
        "author": "",
        "name": "",
        "id": 46,
        "type": "topImage",
        "url": "https://img.alicdn.com/imgextra/i3/376771766/O1CN01AdWaY31Ous2Ny5EQI_!!376771766.jpg "
      },
      {
        "author": "",
        "name": "",
        "id": 47,
        "type": "topImage",
        "url": "https://img.alicdn.com/imgextra/i2/376771766/O1CN01cUajpW1Ous2KjZDAI_!!376771766.jpg "
      },
      {
        "author": "",
        "name": "",
        "id": 48,
        "type": "topImage",
        "url": "https://img.alicdn.com/imgextra/i1/376771766/O1CN01XppS7L1Ous2Kjakn3_!!376771766.jpg "
      },
      {
        "author": "",
        "name": "",
        "id": 49,
        "type": "topImage",
        "url": "https://img.alicdn.com/imgextra/i4/376771766/O1CN01a8haJW1Ous2Ny3QBJ_!!376771766.jpg "
      },
      {
        "author": "",
        "name": "",
        "id": 50,
        "type": "topImage",
        "url": "https://img.alicdn.com/imgextra/i3/376771766/O1CN01gae7uD1Ous2OLo1jj_!!376771766.jpg "
      },
      {
        "author": "",
        "name": "",
        "id": 51,
        "type": "topImage",
        "url": "https://img.alicdn.com/imgextra/i4/376771766/O1CN01KHaGVA1Ous2PCZ9kb_!!376771766.jpg "
      },
      {
        "author": "",
        "name": "",
        "id": 52,
        "type": "topImage",
        "url": "https://img.alicdn.com/imgextra/i4/376771766/O1CN01Nvf28n1Ous2Ny4te5_!!376771766.jpg"
      },
      {
        "author": "",
        "name": "",
        "id": 53,
        "type": "topImage",
        "url": "https://img.alicdn.com/imgextra/i2/376771766/O1CN01sr8lYT1Ous2G44xrL_!!376771766.jpg "
      },
      {
        "author": "",
        "name": "",
        "id": 54,
        "type": "topImage",
        "url": "https://img.alicdn.com/imgextra/i3/376771766/O1CN01QYsNpe1Ous2No2Qzt_!!376771766.jpg "
      },
      {
        "author": "",
        "name": "",
        "id": 55,
        "type": "topImage",
        "url": "https://img.alicdn.com/imgextra/i4/376771766/O1CN01mzRkGB1Ous2LgIBDX_!!376771766.jpg "
      },
      {
        "author": "",
        "name": "",
        "id": 56,
        "type": "topImage",
        "url": "https://img.alicdn.com/imgextra/i1/376771766/O1CN01cMOhql1Ous2OLngxK_!!376771766.jpg "
      },
      {
        "author": "",
        "name": "",
        "id": 57,
        "type": "topImage",
        "url": "https://img.alicdn.com/imgextra/i3/376771766/O1CN01ePH2Cb1Ous2RMFNck_!!376771766.jpg "
      },
      {
        "author": "",
        "name": "",
        "id": 58,
        "type": "topImage",
        "url": "https://img.alicdn.com/imgextra/i1/376771766/O1CN01fjfQL21Ous2QoS6rS_!!376771766.jpg "
      },
      {
        "author": "",
        "name": "",
        "id": 59,
        "type": "topImage",
        "url": "https://img.alicdn.com/imgextra/i1/376771766/O1CN01wFNzU71Ous2OLnUV0_!!376771766.jpg "
      },
      {
        "author": "",
        "name": "",
        "id": 60,
        "type": "topImage",
        "url": "https://img.alicdn.com/imgextra/i2/376771766/O1CN013DXJ5O1Ous2PovnTJ_!!376771766.jpg "
      },
      {
        "author": "",
        "name": "",
        "id": 61,
        "type": "topImage",
        "url": "https://img.alicdn.com/imgextra/i3/376771766/O1CN01601VSf1Ous2RMH3WM_!!376771766.jpg "
      },
      {
        "author": "",
        "name": "",
        "id": 62,
        "type": "topImage",
        "url": "https://img.alicdn.com/imgextra/i2/376771766/O1CN013UPdeo1Ous2No1tkC_!!376771766.jpg "
      },
      {
        "author": "",
        "name": "",
        "id": 63,
        "type": "topImage",
        "url": "https://img.alicdn.com/imgextra/i3/376771766/O1CN01JoCV1s1Ous2Q0yCdo_!!376771766.jpg "
      },
      {
        "author": "",
        "name": "",
        "id": 64,
        "type": "topImage",
        "url": "https://img.alicdn.com/imgextra/i2/376771766/O1CN01zmIojP1Ous2M34Hn4_!!376771766.jpg "
      },
      {
        "author": "",
        "name": "",
        "id": 65,
        "type": "topImage",
        "url": "https://img.alicdn.com/imgextra/i1/376771766/O1CN01K2Qph31Ous2RMEqMz_!!376771766.jpg "
      },
      {
        "author": "",
        "name": "",
        "id": 66,
        "type": "topImage",
        "url": "https://img.alicdn.com/imgextra/i1/376771766/O1CN01qu705m1Ous2Poun7t_!!376771766.jpg "
      },
      {
        "author": "",
        "name": "",
        "id": 67,
        "type": "topImage",
        "url": "https://img.alicdn.com/imgextra/i4/376771766/O1CN01WiaBm11Ous2PCaZ3f_!!376771766.jpg"
      },
      {
        "author": "",
        "name": "",
        "id": 68,
        "type": "topImage",
        "url": "https://img.alicdn.com/imgextra/i1/376771766/O1CN01BGfS9q1Ous2S0W6zz_!!376771766.jpg "
      },
      {
        "author": "",
        "name": "",
        "id": 69,
        "type": "topImage",
        "url": "https://img.alicdn.com/imgextra/i4/376771766/O1CN01wn5bJu1Ous2Q0yKwd_!!376771766.jpg "
      },
      {
        "author": "",
        "name": "",
        "id": 70,
        "type": "topImage",
        "url": "https://img.alicdn.com/imgextra/i1/376771766/O1CN01KknXZb1Ous2RMGS7z_!!376771766.jpg "
      },
      {
        "author": "",
        "name": "",
        "id": 76,
        "type": "topImage",
        "url": "https://img.alicdn.com/imgextra/i1/376771766/O1CN018mH07w1Ous2OIlqQo_!!376771766.jpg "
      },
      {
        "author": "",
        "name": "",
        "id": 77,
        "type": "topImage",
        "url": "https://img.alicdn.com/imgextra/i4/376771766/O1CN01iIYZxD1Ous2Ny66Tx_!!376771766.jpg "
      },
      {
        "author": "",
        "name": "",
        "id": 78,
        "type": "topImage",
        "url": "https://img.alicdn.com/imgextra/i3/376771766/O1CN01DCXRZs1Ous2LgI2vj_!!376771766.jpg "
      },
      {
        "author": "",
        "name": "",
        "id": 79,
        "type": "topImage",
        "url": "https://img.alicdn.com/imgextra/i2/376771766/O1CN019rdqYG1Ous2SQaVac_!!376771766.jpg "
      },
      {
        "author": "",
        "name": "",
        "id": 80,
        "type": "topImage",
        "url": "https://img.alicdn.com/imgextra/i4/376771766/O1CN01c1uyE91Ous2NVa3eR_!!376771766.jpg "
      },
      {
        "author": "",
        "name": "",
        "id": 81,
        "type": "topImage",
        "url": "https://img.alicdn.com/imgextra/i4/376771766/O1CN01u5mxDR1Ous2OLmDYR_!!376771766.jpg "
      },
      {
        "author": "",
        "name": "",
        "id": 82,
        "type": "topImage",
        "url": "https://img.alicdn.com/imgextra/i1/376771766/O1CN01jvGugS1Ous2Q0zwhw_!!376771766.jpg "
      },
      {
        "author": "",
        "name": "",
        "id": 83,
        "type": "topImage",
        "url": "https://img.alicdn.com/imgextra/i1/376771766/O1CN01GEqP5c1Ous2SQbJSP_!!376771766.jpg "
      },
      {
        "author": "",
        "name": "",
        "id": 84,
        "type": "topImage",
        "url": "https://img.alicdn.com/imgextra/i4/376771766/O1CN014e9Mp21Ous2Ny4xqK_!!376771766.jpg "
      },
      {
        "author": "",
        "name": "",
        "id": 85,
        "type": "topImage",
        "url": "https://img.alicdn.com/imgextra/i1/376771766/O1CN01HwxzV91Ous2SQZhkK_!!376771766.jpg "
      },
      {
        "author": "",
        "name": "",
        "id": 86,
        "type": "topImage",
        "url": "https://img.alicdn.com/imgextra/i3/376771766/O1CN014v2ptG1Ous2OLnpJf_!!376771766.jpg "
      },
      {
        "author": "",
        "name": "",
        "id": 87,
        "type": "topImage",
        "url": "https://img.alicdn.com/imgextra/i3/376771766/O1CN014MVgNs1Ous2No0pEV_!!376771766.jpg "
      },
      {
        "author": "",
        "name": "",
        "id": 88,
        "type": "topImage",
        "url": "https://img.alicdn.com/imgextra/i4/376771766/O1CN01QSPfcM1Ous2M3398H_!!376771766.jpg "
      },
      {
        "author": "",
        "name": "",
        "id": 89,
        "type": "topImage",
        "url": "https://img.alicdn.com/imgextra/i1/376771766/O1CN01KP5aTG1Ous2SQYhNY_!!376771766.jpg "
      },
      {
        "author": "",
        "name": "",
        "id": 90,
        "type": "topImage",
        "url": "https://img.alicdn.com/imgextra/i4/376771766/O1CN0104GQhL1Ous2S0Xeca_!!376771766.jpg "
      },
      {
        "author": "",
        "name": "",
        "id": 91,
        "type": "topImage",
        "url": "https://img.alicdn.com/imgextra/i2/376771766/O1CN01UAXbpa1Ous2LgIiTg_!!376771766.jpg "
      },
      {
        "author": "",
        "name": "",
        "id": 92,
        "type": "topImage",
        "url": "https://img.alicdn.com/imgextra/i3/376771766/O1CN01Ktkztf1Ous2PCcZpL_!!376771766.jpg "
      },
      {
        "author": "",
        "name": "",
        "id": 93,
        "type": "topImage",
        "url": "https://img.alicdn.com/imgextra/i4/376771766/O1CN01Pe6rDd1Ous2QoSB44_!!376771766.jpg "
      },
      {
        "author": "",
        "name": "",
        "id": 94,
        "type": "topImage",
        "url": "https://img.alicdn.com/imgextra/i2/376771766/O1CN01KOsIFZ1Ous2PowwCZ_!!376771766.jpg"
      },
      {
        "author": "",
        "name": "",
        "id": 95,
        "type": "topImage",
        "url": "https://img.alicdn.com/imgextra/i2/376771766/O1CN01WAjWYL1Ous2OLoUsw_!!376771766.jpg "
      },
      {
        "author": "",
        "name": "",
        "id": 96,
        "type": "topImage",
        "url": "https://img.alicdn.com/imgextra/i4/376771766/O1CN01ILgj871Ous2S0XaTb_!!376771766.jpg "
      }
    ],
  },
  onLoad(e) {
    // this.loadData()
    let boxImageList = this.data.imageList.filter(item => item.type == 'boxImage');
    let topImageList = this.data.imageList.filter(item => item.type == 'topImage');
    let bgMusicList = this.data.imageList.filter(item => item.type == 'bgMusic');
    this.setData({
      boxImageList: boxImageList,
      topImageList: topImageList,
      bgMusicList: bgMusicList
    })
  },
  async choose(e) {
    let id = e.currentTarget.dataset.id;
    console.log(id)
    let info = this.data.imageList.find(item => item.id == id);
    let sendData = {};
    if (info.type == 'topImage') {
      sendData = { shop_id: getApp().globalData.shop_id, topImage: info.url }
    }
    if (info.type == 'boxImage') {
      sendData = { shop_id: getApp().globalData.shop_id, boxImage: info.url }
    }
    if (info.type == 'bgMusic') {
      sendData = { shop_id: getApp().globalData.shop_id, bgMusic: info.url, bgMusicName: info.name, bgMusicAuthor: info.author }
    }
    const res = await cloud.application.httpRequest({
      path: '/index.php/index/qn/set',
      method: 'POST',
      params: sendData
    })
    my.alert({
      title: '设置成功，返回之后再次刷新页面可以看到设置效果',
      success: (res) => {
        my.navigateTo({
          url: '/pages/index/index'
        });
      }
    });

    // my.navigateTo({
    //   url:`/pages/index/index?info=${JSON.stringify(info)}`
    // })
  },
  async loadData() {

    const res = await cloud.application.httpRequest({
      path: '/index.php/index/qn/getmedia',
      method: 'GET',
      params: {
        shop_id: getApp().globalData.shop_id
      }
    });
    this.setData({
      imageList: res
    })
  }
});
